/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package wiView.graphics.ScenarioMaker;

import java.util.ArrayList;
import wiBase.WiException;
import wiEngine.WiEngine;
import wiView.graphics.UI.GraphForm;
import wiView.graphics.UI.GraphFormPanel;
/**
 *
 * @author Hoang
 */
public class Simulation {
    WiEngine engine;
    GraphFormPanel form;
    public Simulation(WiEngine e, GraphFormPanel graphFormPanel){
        engine = e;
        form = graphFormPanel;
    }
    public void setNodesToSim(ArrayList<String> nodes) throws WiException{
        if(engine == null)
            return;
        ArrayList<Integer> myNodes = new ArrayList<>();
        for (String node : nodes) {
            myNodes.add(Integer.parseInt(node));
        }
        form.DrawNodes(myNodes);
        engine.addTraceNodes(myNodes, null);
    }
    public void setPacketsToSim(ArrayList<String> packets) throws WiException{
        if(engine == null)
            return;
        engine.addTracePackets(packets, null);
    }
    public void Run(long start, long end) throws InterruptedException{
        if(engine == null)
            return;
        engine.setStartTime(start);
        engine.setEndTime(end);
        engine.run();
    }
    public void setStartTime(long start){
        engine.setStartTime(start);
    }
    public void setEndTime(long end){
        engine.setEndTime(end);
    }
    public void Start() throws InterruptedException{
        if(engine == null)
            return;
        engine.run(-1, -1);
        //engine.startSimulation(-1, -1);
    }
    public void Run(){
        if(engine == null)
            return;
        engine.run();
    }
    public void Pause(){
        if(engine == null)
            return;
        engine.pause();
    }
}
